﻿#region Copyright

// All Material Copyright © 2010 Dynamic Concepts Development Corp., All Rights Reserved.
//      Portions Copyright © 1984-2009 Dynamic Concepts Development Corp., All Rights Reserved.
// For further information please contact: SoftwareSupport@dynconcepts.com
// Dynamic Concepts Development Corp.  311 W 57th St. Suite #422, New York, NY 10019

#endregion

#region Using References

using System;

#endregion

namespace DynConDevCorp.OpenArch.SupportLibrary.Serialization
{
    internal class UriReaderWriter : IReaderWriter
    {
        #region Public Properies and Indexers

        public Type DataType
        {
            get { return typeof (Uri); }
        }

        #endregion

        #region Public Methods

        public object ConvertFromString(string src)
        {
            if (src == String.Empty)
                return null;
            Uri uri = new Uri(src);
            return uri;
        }

        public string ConvertToString(object src)
        {
            if (src == null)
                return String.Empty;
            if (!DataType.IsAssignableFrom(src.GetType()))
            {
                throw new Exception();
            }
            Uri uri = src as Uri;
            return uri.OriginalString;
        }

        #endregion
    }
}